﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RENIEC.Entities;
using System.Data.SqlClient;
using System.Data;

namespace RENIEC.DataAccess
{
    public class DAOReniec
    {

        /************************************************************************************************
        *                          J. SALCEDO MAESTROPERSONAL
        * **********************************************************************************************/

        public BEReniec BuscarPersonaXDNI(String DNI)
        {

            string sql = "SP_BUSCAR_PERSONA_X_DNI";

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.Parameters.Add("@DNI", SqlDbType.VarChar).Value = DNI;

            sqlCommand.CommandText = sql;
            sqlCommand.CommandType = CommandType.StoredProcedure;

            using (DataAccess adoDataService = new DataAccess())
            {
                BEReniec _BEReniec = new BEReniec();
                IDataReader dr = adoDataService.ExecuteReader(sqlCommand);
                if (dr.Read())
                {
                    _BEReniec.DNI = Convert.ToString(dr["DNI"]);
                    _BEReniec.NOMBRE = Convert.ToString(dr["NOMBRE"]);
                    _BEReniec.APEPAT = Convert.ToString(dr["APEPAT"]);
                    _BEReniec.APEMAT = Convert.ToString(dr["APEMAT"]);
                }

                dr.Close();

                adoDataService.Dispose();

                return _BEReniec;
            }

        }

      


    }
}
